//C17.21:strout.cpp -- incore formatting (output)
#include <iostream>
#include <sstream>
#include <string>

int main(void)
{
    using namespace std;
    ostringstream outstr;    // manages a string stream
    string hdisk;
    cout << "What's the name of your hard disk?";
    getline(cin, hdisk);
    int cap;
    cin >> cap;
    // write formatted information to string stream
    outstr << "The hard disk " << hdisk << " has a capacity of "
           << cap << " gigabytes.\n";
    string result = outstr.str();    // save result
    cout << result;                  // show contents       
}